package com.tyut.controller;

import com.tyut.entity.Address;
import com.tyut.entity.Files;
import com.tyut.entity.Merchant;
import com.tyut.service.AddressService;
import com.tyut.service.MerchantService;
import com.tyut.vo.ResultJson;
import io.minio.errors.*;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

/**
 * <p>
 * 商家表 前端控制器
 * </p>
 *
 * @author 山田凉
 * @since 2025-03-18
 */
@RestController
@RequestMapping("/merchant")
public class MerchantController {
    @Resource
    MerchantService merchantService;


    @PostMapping("/apply")
    ResultJson applyForMerchant(Merchant merchant,Address address ,MultipartFile MerPicture ,MultipartFile MerCheckPhoto) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
        return ResultJson.success(merchantService.applyForMerchant(merchant,address,MerPicture,MerCheckPhoto));
    }

    @GetMapping("/checkApply")
    ResultJson checkApply(Integer sessionId) {
        return ResultJson.success(merchantService.checkApply(sessionId));
    }


}
